package com.bangbang.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


//    插入式策略
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("derCreateTime",new Date(),metaObject);
        this.setFieldValByName("derUpdateTime",new Date(),metaObject);
    }

//    修改时策略
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("derUpdateTime",new Date(),metaObject);
    }
}
